<table class="tablesorter" id="tab1" >
    <thead>
        <tr>
            <th class="col_date">Date<span class="close">X</span></th>
            <th class="col_site">Site<span class="close">X</span></th>
            <th class="col_homeview">Home View<span class="close">X</span></th>
            <th class="col_morecreditview">More Credit View<span class="close">X</span></th>
            <th class="col_freecredit">Free Credit<span class="close">X</span></th>
            <th class="col_userplay">User Play<span class="close">X</span></th>
            <th class="col_avguserplay">Avg User Play<span class="close">X</span></th>
            <th class="col_long_varianceuserplay">Variance of User Play<span class="close">X</span></th>
            <th class="col_won">Won($)<span class="close">X</span></th>
            <th class="col_expectedwinrate">Expected Win Rate<span class="close">X</span></th>
            <th class="col_expectedvaluepertoken">Expected Value per Token<span class="close">X</span></th>
            <th class="col_variancevaluepertoken">Variance Value per Token<span class="close">X</span></th>
            <th class="col_avgwon">Average Won<span class="close">X</span></th>
            <th class="col_creditwon">Credit Won<span class="close">X</span></th>
            <th class="col_offercompleted">Offer Completed<span class="close">X</span></th>
            <th class="col_avgoffercompleted">Avg Offer Completed<span class="close">X</span></th>
            <th class="col_avgoffer">Avg Offer $<span class="close">X</span></th>
            <th class="col_tokensrewarded">Tokens Rewarded<span class="close">X</span></th>
            <th class="col_avgtokenvalue">Avg Token Value<span class="close">X</span></th>
        </tr>
    </thead>
    <tbody>
    	<?php 
            if((!empty($reportItems)) && $reporttype=="2"):	
                $durations = Util::getReportDuration($duration);
                foreach ($reportItems as $k=>$reportItem):
                	switch($reportItem['game']){
                		case '1':	$evpt = 0.03;	$ewr = '';	break;
                		case '2':	$evpt = 0.21;	$ewr = '64.01%';	break;
                		case '3':	$evpt = 0.25;	$ewr = '';	break;
                	}
			        $date['start'] = $reportItem['date'];
					if($interval == 2){
						list($year, $week) = str_split($reportItem['date'], 4);
						$date = Util::getStartAndEndDate($week, $year);
					}
		?>
                <tr>
                    <td class="col_date"><?php echo $date['start'];?> <?php if($interval==2){ echo '---'.$date['end'];} ?></td>
		            <td class="col_site"><?php echo $reportItem['site']; ?></td>
		            <td class="col_homeview"><?php echo $reportItem['homeview']; ?></td>
		            <td class="col_morecreditview"><?php echo $reportItem['more_credit']; ?></td>
		            <td class="col_freecredit"><?php echo $reportItem['free']; ?></td>
		            <td class="col_userplay"><?php echo $reportItem['total_played']; ?></td>
		            <td class="col_avguserplay"><?php echo Util::divide($reportItem['total_played'], $reportItem['user_num'], 2); ?></td>
		            <td class="col_long_varianceuserplay">Variance of User Play</td>
		            <td class="col_won"><?php echo $reportItem['won']; ?></td>
		            <td class="col_expectedwinrate"><?php echo $ewr; ?></td>
		            <td class="col_expectedvaluepertoken"><?php echo $evpt; ?></td>
		            <td class="col_variancevaluepertoken">Variance Value per Token</td>
		            <td class="col_avgwon"><?php echo Util::divide($reportItem['won'], $reportItem['total_played'], 2); ?></td>
		            <td class="col_creditwon"><?php echo $reportItem['credit']; ?></td>
		            <td class="col_offercompleted"><?php echo $reportItem['offer_num']; ?></td>
		            <td class="col_avgoffercompleted"><?php echo Util::divide($reportItem['offer_num'], $reportItem['user_num'], 2); ?></td>
		            <td class="col_avgoffer"><?php echo Util::divide($reportItem['offer_income'], $reportItem['offer_num'], 2); ?></td>
		            <td class="col_tokensrewarded"><?php echo $reportItem['token']; ?></td>
		            <td class="col_avgtokenvalue"><?php echo Util::divide($reportItem['offer_income'], $reportItem['token'], 2); ?></td>
                </tr>
            <?php
            	endforeach;?>
        <?php endif;?>
    </tbody>
</table>

<script type="text/javascript" src="<?php echo JS_DIR; ?>jquery.tablesorter.js"></script>
<script type="text/javascript" src="<?php echo JS_DIR; ?>jquery.uitablefilter.js"></script>
<script type="text/javascript">
	var $table = $('#tab1');
	$table.tablesorter();
</script>
